import 'package:film/model/vip_model.dart';
import 'package:film/service/api_service.dart';
import 'package:get/get.dart';

class VipController extends GetxController {
  final DioService apiService = DioService();

  // 会员信息
  final vip = VipModel(
    email: '2458225928@qq.com',
    rights: ['看剧不限', '免广告', '专属标识'],
    cards: [
      VipCard(name: '日卡', price: '10'),
      VipCard(name: '周卡', price: '70'),
      VipCard(name: '月卡', price: '300'),
      VipCard(name: '年卡', price: '3600'),
    ],
  ).obs;

  // 当前选中的卡索引
  final selectedIndex = 1.obs; // 默认选中周卡

  // 选中卡
  void selectCard(int index) {
    selectedIndex.value = index;
  }

  // 开通会员
  void openVip() async {
    final ApiResponse<void> response = await apiService.openVipByPoints(openType: vip.value.cards[selectedIndex.value].price);
    if (response.success) {
      Get.snackbar('提示', '开通${vip.value.cards[selectedIndex.value].name}成功！');
    }
  }
}
